﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using SHJunketingModel;
using SHJunketingBLL;
using Web;

public partial class Admin_Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        //if (!IsPostBack)
        //{
        //    if (Request.QueryString["Action"] == "quit")
        //    {
        //        Session["Admin"] = "No";
        //        Web.CommFun.Show_Msg("你已成功安全退出！", "index.aspx");
        //    }
        //}
    }
    protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
    {
        Web.CommFun.HasSqlInjectionChar(this);
        //登录

        string userName = tb_Id.Text.Trim();

        //判断用户是否登录成功
        string sql = "select * from users where userlogin = '" + userName + "' and userPwd = '" + this.tb_Pwd.Text.ToString().Trim() + "'";
        DataTable datatable = DBHelper.GetDataSet(sql);

        if (datatable.Rows.Count > 0)//登录成功
        {
            if (datatable.Rows[0]["loginType"].ToString() == "0")
            {
                Session["userid"] = datatable.Rows[0]["userid"];
                Response.Redirect("UserContent.aspx");
            }
            else
            {
                string permissions = C_UserRoleInfoManager.GetUsrePermissions(Convert.ToInt32(datatable.Rows[0]["userid"]));
                Session["permissions"] = permissions;    //保存权限
                Session["userid"] = datatable.Rows[0]["userid"];
                Session.Timeout = 40360;
                Response.Redirect("Admin_index.aspx");
            }

        }
        else
        {
            Web.CommFun.Show_Msg("帐号或密码错误！");
        }
    }
}
